package org.chuan.base.service.impl;

import org.chuan.base.mapper.BaseMapper;
import org.chuan.base.query.BaseQuery;
import org.chuan.base.service.IBaseService;
import org.chuan.base.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseServiceImpl<T> implements IBaseService<T> {

    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public List<T> queryAll() {
        return baseMapper.queryAll();
    }

    @Override
    public T queryById(Long id) {
        return baseMapper.queryById(id);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public void save(T t) {
        baseMapper.save(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public PageList<T> queryPage(BaseQuery query) {
        Long total = baseMapper.count(query);
        List<T> list = baseMapper.queryPage(query);
        return new PageList<T>(total,list);
    }

    @Override
    public void batchRemove(List<Long> ids) {
        baseMapper.batchRemove(ids);
    }

}
